﻿// --------------------------------------------------------------------------------------------------------------------
// <copyright file="NegationConverter.cs" company="Marcin Jastrzebski">
//   Copyright (c) Marcin Jastrzebski (marcin@marcinj.net)
// </copyright>
// <summary>
//   Converter to negate boolean values.
// </summary>
// --------------------------------------------------------------------------------------------------------------------

namespace mPassRT.Converters
{
    using System;

    using Windows.UI.Xaml;
    using Windows.UI.Xaml.Data;

    /// <summary>Converter to negate boolean values.</summary>
    public class NegationConverter : IValueConverter
    {
        #region Public Methods and Operators

        /// <summary>The convert.</summary>
        /// <param name="value">The value.</param>
        /// <param name="targetType">The target type.</param>
        /// <param name="parameter">The parameter.</param>
        /// <param name="language">The language.</param>
        /// <returns>The <see cref="object"/>.</returns>
        public object Convert(object value, Type targetType, object parameter, string language)
        {
            if (value is bool && targetType == typeof(bool))
            {
                return ((bool)value) == false;
            }

            return DependencyProperty.UnsetValue;
        }

        /// <summary>The convert back.</summary>
        /// <param name="value">The value.</param>
        /// <param name="targetType">The target type.</param>
        /// <param name="parameter">The parameter.</param>
        /// <param name="language">The language.</param>
        /// <returns>The <see cref="object"/>.</returns>
        public object ConvertBack(object value, Type targetType, object parameter, string language)
        {
            return this.Convert(value, targetType, parameter, language);
        }

        #endregion
    }
}